package huichun_r

import (
	"frozen-go-mini/common/domain"
	"frozen-go-mini/common/mycontext"
	"frozen-go-mini/domain/huichun_m"
	"frozen-go-mini/resp"
	"github.com/gin-gonic/gin"
)

type Notice struct {
	ProductId uint64 `json:"product_id"`
	Name      string `json:"name"`
}

// @Tags 挥春
// @Summary 首页公告
// @Param Authorization header string true "token"
// @Success 200 {object} []Notice
// @Router /v1.0/huichun/home/notice [get]
func HomeNotice(c *gin.Context) (*mycontext.MyContext, error) {
	myCtx := mycontext.CreateMyContext(c.Keys)
	model := domain.CreateModelContext(myCtx)
	notices := huichun_m.GetNoticeBar(model)
	var response []Notice
	for _, p := range notices {
		response = append(response, Notice{
			ProductId: p.ProductId,
			Name:      p.Name,
		})
	}

	resp.ResponseOk(c, response)
	return myCtx, nil
}
